<?php
/**
 * Created by PhpStorm.
 * User: 王松
 * Time: 2017/6/23 09:19
 */

namespace App\Project\Filters;

class PhysicalFilter extends FilterAbstract
{
    protected function forExtend()
    {
        $map = [
            'tongue'                 => 1,
            'tongue.color'           => 1,
            'tongue.status'          => 1,
            'tongue.shape'           => 1,
            'tongue.hypoglossis'     => 1,
            'tongue.tongue_coating'  => 1,
            'tongue.coating_color'   => 1,
            'tongue.pulse_condition' => 1,
            'tongue.remark'          => 1,

            'examination.stature'             => 1,
            'examination.weight'              => 1,
            'examination.bmi'                 => 1,
            'examination.blood_pressure.low'  => 1,
            'examination.blood_pressure.high' => 1,
            'examination.pulse'               => 1,
            'examination.waistline'           => 1,
            'examination.thyroid'             => 1,
            'examination.edema'               => 1,
            'examination.skin_rupture'        => 1,
            'examination.large_limb_profile'  => 1,

            'cn_examination.heart_rate'             => 1,
            'cn_examination.heart_rhythm'           => 1,
            'cn_examination.heart_sound'            => 1,
            'cn_examination.liver_spleen_palpation' => 1,
            'cn_examination.thorax'                 => 1,
            'cn_examination.lung_respiratory_sound' => 1,
            'cn_examination.rale'                   => 1,
            'cn_examination.abdominal_mass'         => 1,
            'cn_examination.liver_area_percussion'  => 1,
            'cn_examination.renal_area_percussion'  => 1,

            'other.sfp'                   => 1,
            'other.buffalo_hump'          => 1,
            'other.acanthosis_nigricans'  => 1,
            'other.ecchymosis'            => 1,
            'other.apl'                   => 1,
            'other.pericardial_fricative' => 1,
            'other.pleural_fricative'     => 1,
            'other.murphy_character'      => 1,
            'other.moving_dullness'       => 1,
            'other.ankle_reflex'          => 1,
            'other.btnp'                  => 1,
            'other.bttfvs'                => 1,
            'other.10gnt'                 => 1,
        ];

        return array_merge($map, $this->tongue());
    }

    protected function tongue()
    {
        $map    = [];
        $tongue = $this->request->input('tongue');

        if (!empty($tongue)) {
            $keys = ['color', 'status', 'shape', 'hypoglossis', 'tongue_coating', 'coating_color', 'pulse_condition','remark'];

            foreach ($keys as $key) {
                if (array_key_exists($key, $tongue)) {
                    $map['tongue'][$key] = array_pad([], count($tongue[$key]), 1);
                }
            }
        }

        return $map;
    }

    protected function getRootFieldsHasNoSon()
    {
        return ['id', 'record_id', 'tongue', 'examination', 'other', 'remark'];
    }

    protected function getRootFieldsHasSon()
    {
        return [];
    }

    protected function getSonFieldsForEachRoot()
    {
        return [];
    }
}